<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<title>高级搜索 - PublicCMS</title>
	<meta name="keywords" content="高级搜索,分面搜索,智能搜索"/>
	<meta name="description" content="高级搜索  ${word!}"/>
	<@tools.includePlace path="/76c53ac2-4f88-4ef3-984b-c81d00a48089.html"/> <#-- 头部Header -->
</head>
<body>
<@tools.includePlace path="/23e95a91-0063-4498-99ef-aa3fc4a79c4c.html"/> <#-- 导航 -->
<main>
	<div class="container bread">
		<a href="${site.sitePath}">首页</a>  &gt; <a href="${site.dynamicPath}search/facet.html">高级搜索</a>
	</div>
	<div class="container clearfix-after">
		<div class="data-list left-content">
			<div class="search">
				<form action="facet.html" method="get">
					<div class="search-box">
						<input type="text" name="word" value="${word!}"/>					
						<input type="submit" class="button" value="搜索"/>
					</div>
					<#if categoryId?has_content><input type="hidden" name="categoryId" value="${categoryId!}"/></#if>
					<#if modelId?has_content><input type="hidden" name="modelId" value="${modelId!}"/></#if>
				<#if dictionaryValues?has_content>
					<#list dictionaryValues as d>
						<input type="hidden" name="dictionaryValues" value="${d}"/>
					</#list>
				</#if>
				<#if tagId?has_content>
					<#list tagId as t>
						<input type="hidden" name="tagId" value="${t}"/>
					</#list>
				</#if>
				</form>
				<@cms.tagList count=10>
					<p>
						热门标签：
						<#list page.list as a>
							<a href="?tagId=${a.id}">${a.name}</a>
						</#list>
					</p>
				</@cms.tagList>
				<@cms.wordList count=10>
					<p>
						热门搜索词：
						<#list page.list as a>
							<a href="?word=${a.name?url}">${a.name}</a>
						</#list>
					</p>
				</@cms.wordList>
			</div>
		<@import path="/ftl/tools.ftl" namespace="t"/>
		<@cms.facetSearch word=word tagId=tagId categoryId=categoryId dictionaryValues=dictionaryValues modelId=modelId highlight=true pageIndex=pageIndex pageSize=10>
			<#if (page.facetMap.categoryId)?has_content||categoryId?has_content>
				<div class="search-condition">
					<label>分类:</label>
						<#if categoryId?has_content>
							<@cms.category id=categoryId><#assign firstCategory=object/>${object.name} <a href="javascript:search('categoryId','');">X</a></@cms.category>
						<#else>
							<#list page.facetMap.categoryId?keys as k><@t.merge 'categoryIds' k/></#list>
							<@cms.category ids=(t.categoryIds)!><#assign categoryMap=map!/></@cms.category>
							<#list page.facetMap.categoryId?keys as k>
								<#if k?is_first><#assign firstCategory=categoryMap[k]/></#if>
							<a href="javascript:search('categoryId','${k}');" ${(k=categoryId!'')?then('style="font-weight:bold;"','')?no_esc}>${categoryMap[k].name}(${page.facetMap.categoryId[k]})</a>
							</#list>
						</#if>
				</div>
			</#if>
			<#if (page.facetMap.modelId)?has_content||modelId?has_content>			
				<div class="search-condition">
					<label>模型:</label>											
					<#if modelId?has_content>
						<@cms.model id=modelId><#assign firstModel=object/>${object.name} <a href="javascript:search('modelId','');">X</a></@cms.model>
					<#else>
						<#list page.facetMap.modelId?keys as k><@t.merge 'sidemodelIds' k/></#list>
						<@cms.model ids=(t.sidemodelIds)!><#assign modelMap=map!/></@cms.model>	
						<#list page.facetMap.modelId?keys as k>
							<#if k?is_first><#assign firstModel=modelMap[k]/></#if>
							<a href="javascript:search('modelId','${k}');">${modelMap[k].name}(${page.facetMap.modelId[k]})</a>
						</#list>
					</#if>						
				</div>
			</#if>
	<@cms.tag ids=tagId>
		<#if map?has_content>
			<div class="search-condition">
				<label>标签:</label>
				<#list map?keys as k>${map[k].name} <a href="javascript:search('tagId','');">X</a></#list>
			</div>
		</#if>
	</@cms.tag>
		<#macro dictionarySearch extendList>
			<#list extendList as extend>
				<div class="search-condition">
						<@cms.dictionary id=extend.dictionaryId>
					<label>${object.name}:</label>
						<a href="javascript:search('dictionaryValues','');" ${(!dictionaryValues?has_content)?then('style="font-weight:bold;"','')?no_esc}>全部</a>
						<@cms.dictionaryDataList dictionaryId=object.id.id>
							<#list list as d>
						<a href="javascript:search('dictionaryValues','${extend.id.code}_${d.id.value!}');" ${(dictionaryValues?has_content && dictionaryValues?seq_contains(extend.id.code+'_'+d.id.value))?then('style="font-weight:bold;"','')?no_esc}>${d.text}</a>
							</#list>
						</@cms.dictionaryDataList>
					</@cms.dictionary>
				</div>
			</#list>
		</#macro>
		<#if (firstCategory.extendId)?has_content>
			<@sys.extendFieldList extendId=firstCategory.extendId inputType='dictionary' searchable=true>
				<@dictionarySearch list/>
			</@sys.extendFieldList>
		</#if>
		<#if (firstModel.extendList)?has_content>
			<@dictionarySearch firstModel.extendList/>
		</#if>
		<#if page.totalCount gt 0>
			<ul data-diy="content">
			<#list page.list as a>
					<@include path="/ftl/search-list.ftl"/><#-- 搜索列表 -->
			</#list>
			</ul>
			<div class="page">
				<#if !page.firstPage>
				<a href="javascript:search('pageIndex',${page.prePage});">上一页</a>
				<#else>
				<span>上一页</span>
				</#if>
				<#assign start=1/>
				<#if (page.pageIndex-5) gt start>
				<#assign start=page.pageIndex-4/>
				</#if>
				<#assign end=page.totalPage/>
				<#if (page.pageIndex+5) lt end>
				<#assign end=page.pageIndex+4/>
				</#if>
				<#if start gt 1>
				<a href="javascript:search('pageIndex',1);">1</a> ...
				</#if>
				<#list start..end as n><a href="javascript:search('pageIndex',${n});"<#if n=page.pageIndex> class="selected"</#if>>${n}</a></#list>
				<#if end lt page.totalPage>
				... <a href="javascript:search('pageIndex',${page.totalPage});">${page.totalPage}</a>
				</#if>
				<#if !page.lastPage>
				<a href="javascript:search('pageIndex',${page.nextPage});">下一页</a>
				<#else>
				<span>下一页</span>
				</#if>
			</div>
		</#if>
	</@cms.facetSearch>
		</div>
		<aside>
			<@tools.includePlace path="/49d393ca-f0f1-4723-a9b0-6f9b6d7cc04d.html"/> <#-- 编辑推荐 -->
			<@tools.includePlace path="/3435e9a7-565a-4f93-8670-9c272a1d51cc.html"/> <#-- 精彩图集 -->
		</aside>
	</div>
</main>
	<script>
		var templatePath='${.current_template_name?keep_after('/')}';
	</script>
<@tools.includePlace path="/cc29e896-332a-46d8-9bcb-d48e92144e9c.html"/> <#-- 尾部Footer -->
	<script>
		function search(name,value){
			var $form = $('.search form');
			var $input = $form.find('input[name='+name+']');
			if(0 == $input.length && value){
				$input = $('<input type="hidden"/>').attr('name',name).appendTo($form);						
			}
			if(value){
				$input.val(value);
			}else{
				$input.remove();
			}
			$form.submit();
			return false;
		}
	</script>
</body>
</html>
